package com.gwcm.controller;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.gwcm.service.ILoginService;
import com.yhz.commonutil.common.BaseResponse;
import com.yhz.commonutil.common.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

/**
 * @author yanhuanzhan
 * @date 2023/3/27 - 19:28
 */
@RestController
@RequestMapping("/oauth")
@Api(tags = "oauth2.0 认证")
public class OauthController {
    @Resource
    private ILoginService loginService;
    @ApiOperation("qq获取跳转url接口")
    @GetMapping("/url/qq")
    public BaseResponse<String> getQQUrl() {
        String url=loginService.getOauthUrl();
        return ResultUtils.success(url);
    }
    @ApiOperation("Gitee重定向接收授权码接口")
    @GetMapping("/qq/redirect")
    public void giteeRedirect(String code, HttpServletResponse response) throws IOException {
        loginService.oauthLogin(code, response);
    }
}
